package com.znjc.device.domain.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.znjc.device.util.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("iot_data")
public class IotData {
    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 时间戳
     */
    private Timestamp ts;
    private String dz;
    private String dzUnit;
    private String dl;
    private String dlUnit;
    private String dy;
    private String dyUnit;
    private String pl;
    private String plUnit;
    private String dzl;
    @TableField
    private String dzlUnit="Ω·m";
    /**
     * 地址位号
     */
    private String address;


    private Long deviceId;
    @TableField(exist = false)
    private String deviceName;
    private Long pointId;
    /**
     *  0电阻 1电压
     */
    private String dataType;
    /**
     *  0正常，1告警
     */
    private Integer alarmType;
    @TableField(exist = false)
    private String tsString;

    public String getTsString(){
        try {
            return DateUtil.TimestampToString(this.getTs());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
